home *** CD-ROM | disk | FTP | other *** search
Wrap
var cpvw_highlightManager={contextIconTimer:null,parentDoc:null,isShowingIcon:false,selectedText:"",posX:null,posY:null,iconHoverTimer:null,iconHoverInterval:500,hideMenuTimer:null,isShowingMenu:false,contextIcon:null,handleEvent:function(_1){ var _2=cpvw_prefHandler.getPref(cpvw_Prefs.prefInlineSubsearch); if(!_2){ return; } if(_1.type=="mouseup"){ if(this.parentDoc&&cpvw_get("cpvw_contextIcon",this.parentDoc)){ cpvw_get("cpvw_contextIcon",this.parentDoc).parentNode.removeChild(cpvw_get("cpvw_contextIcon",this.parentDoc)); } if(this.getSelection()!=""){ this.getSelectionPosition(); var _3=this; setTimeout(function(){ _3.showIcon(_1); },500); } } },getSelectionPosition:function(){ var _4=document.commandDispatcher.focusedWindow; var _5=_4.getSelection(); var _6=this.parentDoc.createElement("cpvw"); _6.setAttribute("id","cpvw_temporaryElement"); _6.innerHTML="a"; var _7=_5.getRangeAt(0); var _8=_7.endContainer; var _9=_7.endOffset; var _a=_7.startContainer; var _b=_7.startOffset; var _c=_7.startContainer.parentNode; var _d=this.parentDoc; if(_c&&_c.localName.toLowerCase()=="tbody"||_c.localName.toLowerCase()=="tr"||_c.localName.toLowerCase()=="table"){ return; } var _e=_d.createRange(); if(_7.comparePoint(_7.startContainer,_7.startOffset+1)==0){ try{ _e.setStart(_7.startContainer,_7.startOffset+1); } catch(ex){ var _f=this.findNextTextNode(_d,_7.commonAncestorContainer,_7.startContainer); _e.setStart(_f,1); _c=_f.parentNode; _a=_f; _b=0; } _e.insertNode(_6); this.getPos(_6); }else{ _e.setStart(_7.startContainer,_7.startOffset); _e.insertNode(_6); this.getPos(_6); } _e.deleteContents(); if(cpvw_get("cpvw_temporaryElement",_d)&&cpvw_get("cpvw_temporaryElement",_d).parentNode){ _c=cpvw_get("cpvw_temporaryElement",_d).parentNode; cpvw_get("cpvw_temporaryElement",_d).parentNode.removeChild(cpvw_get("cpvw_temporaryElement",_d)); _c.normalize(); } var _10=_d.createRange(); _10.setStart(_a,_b); _10.setEnd(_8,_9); _5.removeAllRanges(); _5.addRange(_10); },getPos:function(_11){ this.posX=_11.offsetLeft; this.posY=_11.offsetTop; if(_11.offsetParent){ var _12=_11; while(_12.offsetParent){ this.posX+=_12.offsetParent.offsetLeft; this.posY+=_12.offsetParent.offsetTop; _12=_12.offsetParent; } } },getSelection:function(){ var _13=document.commandDispatcher.focusedWindow; this.parentDoc=_13.document; var _14=_13.getSelection(); var _15=cpvw_jsUtils.trimWhitespace(_14.toString()); this.selectedText=_15; return _15; },clearTimer:function(){ clearTimeout(this.contextIconTimer); this.contextIconTimer=null; },showIcon:function(evt){ var _17=this; this.removeIcon(); var _18=this.parentDoc.createElement("img"); _18.setAttribute("src","chrome://cooliris/skin/new/mouseover.png"); _18.setAttribute("id","cpvw_contextIcon"); _18.setAttribute("title","Click on the icon to see the options"); _18.setAttribute("style","z-index:2147483647;border: 0px solid blue;-moz-opacity:0.20;position:absolute;width:20px;height:20px;margin-top:-20px"); _17.contextIcon=_18; var _19=function(){ _18.style.opacity=parseFloat(_18.style.opacity)+0.2; if(parseFloat(_18.style.opacity)<0.9){ setTimeout(_19,75); } }; setTimeout(_19,50); var py=this.posY-21; if(this.posY-21<0){ _18.style.marginTop="0px"; } _18.style.left=(this.posX-10)+"px"; _18.style.top=this.posY+"px"; this.parentDoc.body.appendChild(_18); this.isShowingIcon=true; this.clearTimer(); _18.addEventListener("mouseover",function(evt){ cpvw_get("cooliris_rightclick").openPopup(_18,"overlap",20,20,false,false); },true); _18.addEventListener("click",function(evt){ cpvw_get("cooliris_rightclick").openPopup(_18,"overlap",20,20,false,false); },true); _18.addEventListener("mouseout",function(evt){ clearTimeout(_17.iconHoverTimer); },true); this.contextIconTimer=setTimeout(function(){ _17.removeIcon(); },5000); },initHideMenu:function(){ var _1e=this; this.hideMenuTimer=setTimeout(function(){ cpvw_get("cooliris_rightclick").hidePopup(); _1e.hideMenuTimer=null; _1e.isShowingMenu=false; },1500); },initShowMenu:function(){ if(this.hideMenuTimer){ clearTimeout(this.hideMenuTimer); this.hideMenuTimer=null; } },setContextMenuItems:function(){ while(cpvw_get("cooliris_rightclick").childNodes.length>0){ cpvw_get("cooliris_rightclick").removeChild(cpvw_get("cooliris_rightclick").firstChild); } var _1f=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems); var _20=_1f.split(","); if(cpvw_contextSitesTreeView.arrCMenuItems==null){ cpvw_contextSitesTreeView.loadContextSites(); } var str=""; for(var key in cpvw_contextSitesTreeView.arrCMenuItems){ str+=key+", "; } cpvw_objContextMenu.parentDoc=this.parentDoc; cpvw_objContextMenu.selectStr=this.selectedText; var _23=this; for(var i=0;i<_20.length;i++){ if(cpvw_contextSitesTreeView.arrCMenuItems[_20[i]]!=null){ var _25=document.createElement("menuitem"); _25.setAttribute("label",cpvw_contextSitesTreeView.arrCMenuItems[_20[i]].label); _25.setAttribute("image",cpvw_contextSitesTreeView.arrCMenuItems[_20[i]].image); _25.setAttribute("value",i); _25.setAttribute("class","menuitem-iconic"); _25.addEventListener("command",function(evt){ _23.isShowingMenu=true; cpvw_objContextMenu.initPreviewShow(this,"click",evt); },false); _25.addEventListener("mouseover",function(evt){ cpvw_objContextMenu.initPreviewShow(this); },false); _25.addEventListener("mouseout",function(evt){ cpvw_objContextMenu.initPreviewHide(); },false); cpvw_get("cooliris_rightclick").appendChild(_25); } } _25=document.createElement("menuitem"); _25.setAttribute("label","Disable this feature"); _25.setAttribute("value",i); _25.setAttribute("class","menuitem-iconic"); _25.addEventListener("command",function(evt){ _23.isShowingMenu=false; cpvw_prefHandler.setPref(cpvw_Prefs.prefInlineSubsearch,false); setTimeout(function(){ cpvw_Prefs.showStatusMenu(); },100); var _2a=cpvw_get("cooliris_status_menu"); setTimeout(function(){ _2a.hidePopup(); },4000); },false); cpvw_get("cooliris_rightclick").appendChild(_25); _25=document.createElement("menuitem"); _25.setAttribute("label","Add more >>"); _25.setAttribute("value",i); _25.setAttribute("class","menuitem-iconic"); _25.addEventListener("command",function(evt){ _23.isShowingMenu=false; cpvw_Prefs.showPrefDialog(evt,true); },false); cpvw_get("cooliris_rightclick").appendChild(_25); this.isShowingMenu=true; },removeIcon:function(){ var _2c=this; if(this.isShowingMenu){ this.contextIconTimer=setTimeout(function(){ _2c.removeIcon(); },5000); return; } var _2d=_2c.parentDoc.getElementById("cpvw_contextIcon"); if(_2d!=null){ _2c.parentDoc.body.removeChild(_2d); clearTimeout(_2c.contextIconTimer); _2c.contextIconTimer=null; this.isShowingIcon=false; _2c.contextIcon=null; }else{ if(_2c.contextIcon&&_2c.contextIcon.parentNode){ _2c.contextIcon.parentNode.removeChild(_2c.contextIcon); _2c.contextIcon=null; } } },findNextTextNode:function(_2e,_2f,_30){ var _31=_2e.createTreeWalker(_2f,NodeFilter.SHOW_TEXT,null,false); while(_31.nextNode()){ if(cpvw_jsUtils.trimWhitespace(_31.currentNode.nodeValue)!=""&&_30!=_31.currentNode){ return _31.currentNode; } } }}; function cpvw_fireEvent(_32,_33,_34,doc){ if(doc==null){ doc=document; } var evt=doc.createEvent("Events"); evt.initEvent(_32,true,true); for(var _37 in _34){ evt[_37]=_34[_37]; } _33.dispatchEvent(evt); }